package com.SoilMM.service.impl;

import com.SoilMM.entity.UserEntity;
import com.SoilMM.mapper.UserMapper;
import com.SoilMM.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Gramorgan
 * @since 2021-07-04
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> implements UserService {

    @Override
    public List<UserEntity> search(String userName) {
        QueryWrapper<UserEntity> wrapper=new QueryWrapper<>();
        wrapper.like("user_name",userName);
        List<UserEntity> list=baseMapper.selectList(wrapper);

        return list;
    }

    @Override
    public boolean doLogin(UserEntity userEntity) {
        QueryWrapper<UserEntity> wrapper=new QueryWrapper<>();
        wrapper.eq("user_name",userEntity.getUserName());
        wrapper.eq("pass_word",userEntity.getPassWord());

        UserEntity userEntity1=baseMapper.selectOne(wrapper);
        if (userEntity1!=null)
            return true;
        else
            return false;
    }
}